package com.example.skycode5.servlet;

import com.example.skycode5.bean.NewsBean;
import com.example.skycode5.dao.NewsDao;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/newsDetail.html")
public class NewsDetailServelt extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        String newsId = req.getParameter("newsId");
        int id=Integer.parseInt(newsId);
        NewsBean newsBean = (new NewsDao().getNewsById(id)) ;
        req.setAttribute("title", newsBean.getNewsTitle());
        req.setAttribute("content", newsBean.getNewsContent());
        req.getRequestDispatcher("newsFrontDetail.jsp").forward(req, resp);
    }
}
